package com.gitee.Transformation.partition

import org.apache.flink.api.common.functions.RichMapFunction
import org.apache.flink.api.common.typeinfo.TypeInformation
import org.apache.flink.api.scala.DataSet
import org.apache.flink.api.scala._

import scala.reflect.ClassTag

class PartitionInspector {
  def inspector[R: TypeInformation: ClassTag](data: DataSet[R]): Unit = {
    data.map(new RichMapFunction[R, (Long, Long)] {
      override def map(value: R): (Long, Long) = {
        val index: Long = getRuntimeContext.getIndexOfThisSubtask
        (index,1)
      }
    }).groupBy(0).reduceGroup(iter => iter.reduce((t1, t2) => (t1._1, t1._2 + t2._2))).print()
  }
}
